$(function(){
	$("#register").click(function(){
		//获取邮箱
		var email = $("#email").val();
		//获取密码
		var password = $("#password").val();
		//获取确认密码
		var confirmPassword = $("#confirmPassword").val();
		//获取验证码
		var code = $("#code").val();
		if(!email){
			alert("请输入邮箱");
			return;
		}
		if(!password){
			alert("请输入密码");
			return;
		}
		if(password == confirmPassword){
			
		}else{
			alert("两次密码输入不一致");
			return;
		}
		//AJAX调用后台接口
		$.ajax({
			url:'/api/user/register/'+encodeURI(email)+'/'+password+'/'+code+'',
			type:'POST',
			success:function(data){
				alert(data);
				if(data == true){
					alert("注册成功");
					window.location.href = "login.html";
				}else{
					alert("验证码错误或超时");
				}
			}
		})
	})
	$("#getCode").click(function(){
		var email = $("#email").val();
		if(!email){
			alert("请输入邮箱");
			return;
		}
		//AJAX调用后台接口
		$.ajax({
			url:'/api/code/create/'+email+'',
			type:'POST',
			success:function(data){
				alert("已发送");
			}
		})
	})
})